﻿//global counter
var currentQuestion = 0;
//constructor
var questions = function (question, answerA, answerB, answerC, rightAnswer) {
    this.question = question;
    this.answerA = answerA;
    this.answerB = answerB;
    this.answerC = answerC;
    this.rightAnswer = rightAnswer;
    this.checked = false;
};

// questions to be pushed into Array
var quest1 = new questions("What is Superman's real name?", "Kal-El" , "Cal", "Carl", "Kal-El" );
var quest2 = new questions("Which super hero wears a green ring?", "Batman", "Wonder Woman", "Green Lantern", "Green Lantern");
var quest3 = new questions("Where does Batman reside?", "New York", "Gotham", "Metropolis", "Gotham");
var quest4 = new questions("Which Justice League member can hack computers?", "Hacker", "Cyborg", "John Coder", "Cyborg");
var quest5 = new questions("Which super hero is faster than Superman?", "Quicksilver", "Ghost Rider", "The Flash", "The Flash");
var quest6 = new questions("Aquaman lives in the famed city of?", "Las Vegas", "Los Angeles", "Atlantis", "Atlantis");
var quest7 = new questions("Which super hero carries a lasso that makes you tell the truth?", "Hulk", "Johnny Blaze", "Wonder Woman", "Wonder Woman");

//array
var arr = [
    quest1,
    quest2,
    quest3,
    quest4,
    quest5,
    quest6,
    quest7
];



var beginQ = function () {
    'use strict'
    var tableStuff = "<table class='table table-striped table-hover'>";
    //for (var i in arr) {
    //    if(arr[i].checked == false)
    //var random = arr[i].question.splice(Math.floor(Math.random() * arr[i].checked.length), 1)[0];4
    var currentH = arr[currentQuestion].question;
        tableStuff += "<tr><td><em>" + currentH + "</em></td></tr>";
        tableStuff += "<tr><td><input type='radio' name='r1'>" + arr[currentQuestion].answerA + "</td></tr>";
        tableStuff += "<tr><td><input type='radio' name='r1'>" + arr[currentQuestion].answerB + "</td></tr>";
        tableStuff += "<tr><td><input type='radio' name='r1'>" + arr[currentQuestion].answerC + "</td></tr>";
    //}
        tableStuff += "</table>";

           
        currentQuestion++;
    document.getElementById("tableHolder").innerHTML = tableStuff;

    
    };
function validateRadios(s) {
    var radios = document.getElementsByName("r1");

    for (var i in radios)
        if (radios[i].value == arr[i].rightAnswer) {
            alert("correct!");
        }
        else {
            alert("Please check one!");
        }
}